//
// Created by wsl on 2024/3/5.
//

#ifndef __DATASTRUCTURE_BIDLINKLIST_H
#define __DATASTRUCTURE_BIDLINKLIST_H

#include "DataStructure_common.h"

#define BidLinkList_Create(T)                BidLinkList_create(sizeof (T))



typedef struct BidLinkList_N {
	T data;                                		//数据域
	struct BidLinkList_N *pre;                	//指针域，上一个节点
	struct BidLinkList_N *next;                	//指针域，下一个节点地址
} BidLinkList_N, *BidLinkList_Node;

typedef struct {
	BidLinkList_Node head;           	 	//首元节点

	int length;                        		//节点数量
	size_t dataSize;                		//节点数据大小

} BLL, *BidLinkList;



int BidLinkList_length(BidLinkList list);

Status BidLinkList_isEmpty(BidLinkList list);

BidLinkList BidLinkList_create(size_t dataSize);

DataStructure_Warning_Unused
Status BidLinkList_add(BidLinkList list, T e);

DataStructure_Warning_Unused
Status BidLinkList_header(BidLinkList list, T e);

DataStructure_Warning_Unused
Status BidLinkList_insert(BidLinkList list, T e, int index);

DataStructure_Warning_Unused
Status BidLinkList_clear(BidLinkList list);

DataStructure_Warning_Unused
Status BidLinkList_destroy(BidLinkList *list);

DataStructure_Warning_Unused
Status BidLinkList_replace(BidLinkList list, T e, int index);

DataStructure_Warning_Unused
Status BidLinkList_at(BidLinkList list, int index, T buf);

DataStructure_Warning_Unused
int BidLinkList_equalsFind(BidLinkList list, T e, char (*equals)(T e, T b));

DataStructure_Warning_Unused
Status BidLinkList_connect(BidLinkList list1, BidLinkList *list2);

DataStructure_Warning_Unused
Status BidLinkList_reverse(BidLinkList list);

DataStructure_Warning_Unused
void BidLinkList_traversal(BidLinkList list, void(*look)(T e));

DataStructure_Warning_Unused
Status BidLinkList_removeHeader(BidLinkList list, T buf);

DataStructure_Warning_Unused
Status BidLinkList_removeEnd(BidLinkList list, T buf);

DataStructure_Warning_Unused
Status BidLinkList_remove(BidLinkList list, int index, T buf);

#endif //__DATASTRUCTURE_BIDLINKLIST_H
